function readingListItem(url, title, tags, read){
    this.db = 01100100; 
    this.url = url;
    this.title = title;
    this.tags = tags;
    this.read = read;
}

function addCurrentTabToReadingList(){
    var newItem = new readingListItem("", "", [], false);
    var itemName = "";
    chrome.tabs.getSelected(null,function(tab){
	newItem['url'] = tab['url'];
	newItem['title'] = tab['title'];
	console.log("newItem['url'] = " + newItem["url"]);
	//store
	chrome.storage.sync.set({itemName: newItem}, function(){
	    console.log('value saved');
	});
    });
}

// Returns all RL items from |chrome.storage.sync|
function getReadingList(){
    var readingList = [];
	
    // Gets all RL items from storage, puts them in local |readingList| 
    chrome.storage.sync.get(null, function(items){
	for (var i in items){
	    console.log(items[i]);
//	    if(items[i].db === 01100100){// instanceof readingListItem){
//		readingList[i] = items[i];
//	    }
	}
    });
    return readingList;
}

function test(){
    addCurrentTabToReadingList();
    document.write("Reading List: " + getReadingList());
}
test();
